Skip to content

Document that include_similar is not bounded by the date window. Closes #1729 - #1811

Merged
regulartim merged 1 commit into
GreedyBear-Project:developfrom
dev-aditya-hub:docs/1729-include-similar-date-window
Nov 3, 2026
Merged

regulartim merged 1 commit into
GreedyBear-Project:developfrom
dev-aditya-hub:docs/1729-include-similar-date-window

Conversation

@dev-aditya-hub

@dev-aditya-hub dev-aditya-hub commented Oct 29, 2026 •

Copy link
Copy Markdown

Description

In #1729 I reported that include_similar returns sessions from outside start_date/end_date. regulartim said this is on purpose and was chosen in #1515. So this PR does not change any behaviour, it only documents it and adds the missing tests. api/views/cowrie_session.py is untouched.

What I changed in api/serializers/cowrie_session.py:

  • include_similar now says the sessions it adds are not bounded by the date window.
  • start_date and end_date now say the window does not apply to sessions added by include_similar, so you can see it from both sides of the docs.

You wrote the sentence about the sessions array. I made it a little wider, because commands, sources and credentials are built after the union at cowrie_session.py:111-127, so they also get data from outside the window. If you prefer your shorter sentence, I will cut it back.

What I added in tests/api/views/test_cowrie_session_view.py (the suite tested the date window and include_similar separately, never together):

  • window 01-15..01-25 with include_similar returns all three cluster sessions (01-10, 01-20, 01-30).
  • the same for the aggregated fields: an out of window session in the same cluster shows up in commands, sources and credentials.
  • an empty window stays empty, because the expansion needs an in window session to take the cluster from. This keeps "not bounded" from turning into "returns the whole cluster for a window that matched nothing".

How I verified:

  • full test suite: 1723 tests, OK.
  • ruff check, ruff format --check and ty check: clean.
  • to check the new tests are not passing by luck, I bounded the expansion again (the fix I first suggested in the issue). Two of the three tests failed. Then I reverted it.

Related issues

Closes #1729. The date window itself comes from #1515 and PR #1621.

Wiki

The Cowrie Session API section in Usage.md does not document start_date/end_date at all, so there is no place there yet to put this note. Tell me if you want me to add those parameters plus one line about include_similar, and I will write it the way you want.

Type of change

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • Chore (refactoring, dependency updates, CI/CD changes, code cleanup, docs-only changes).

Checklist

Formalities

  • I have read and understood the rules about how to Contribute to this project.
  • I chose an appropriate title for the pull request in the form: <feature name>. Closes #999
  • My branch is based on develop.
  • The pull request is for the branch develop.
  • I have reviewed and verified any LLM-generated code included in this PR.

Docs and tests

  • I documented my code changes with docstrings and/or comments.
  • I have checked if my changes affect user-facing behavior that is described in the docs. If so, I also included an update to the wiki in the description of this PR.
  • Linter (Ruff) gave 0 errors.
  • I have added tests for the feature/bug I solved.
  • All the tests gave 0 errors.

GUI changes

No GUI changes.

GreedyBear-Project#1729

The cluster expansion in the Cowrie session view deliberately ignores
start_date and end_date, but nothing said so. The help text for
include_similar now states it, and both date fields point back at the
exception, so it is visible from either side of the API docs.

Because commands, sources and credentials are aggregated after the
expansion, out-of-window data reaches them too, even without
include_session_data. The help text says that as well.

Three tests pin the behaviour, which the suite did not cover before:
the expansion crossing the window, the aggregated fields crossing it,
and an empty window staying empty because the expansion has no
in-window session to take its clusters from.

No behaviour change.

@regulartim regulartim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dev-aditya-hub ! Nice and small fix, thank you!

@regulartim
regulartim merged commit 9fc5b6f into GreedyBear-Project:develop Nov 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants